FROM golang:1.22 AS build
WORKDIR /app

ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
RUN go install github.com/swaggo/swag/cmd/swag@latest

COPY go.mod go.sum ./
COPY taskfile-docker.yml .

COPY . .
RUN ./bin/task -t taskfile-docker.yml install

RUN ./bin/task -t taskfile-docker.yml docs
RUN ./bin/task -t taskfile-docker.yml build:ubuntu

FROM ubuntu:22.04
WORKDIR /app

ENV TZ=Asia/Shanghai
COPY --from=build /app/config/app.yaml ./config/
COPY --from=build /app/target/main ./app

CMD ["./app", "-c", "./config/app.yaml"]
EXPOSE 4936
